import { CommonForm } from "@/pages/OrderModule/common/components/CommonForm";
import { CommonModal, useModal } from "@/views/components/CommonModal";
import SubTitle from "@/pages/OrderModule/common/components/SubTitle";
import Typography from "@/pages/OrderModule/common/components/Typography";
import { Alert, Button, Col, Form, InputNumber, Modal, Radio, Row, Space, Progress, message } from "antd";
import { useEffect, useState } from "react";
import Style from "../index.module.less";

import ProgressModal from "@/views/components/UIModal/ProgressModal";
import ResultModal from "@/views/components/UIModal/ResultModal";

/**上传商品编码 */
function ActionModal(props) {
	console.log("ActionModal(props)", props);

	const { selectedRows, isSkuType } = props;

	const [visible, setVisible] = useState("ProgressModal");

	const [result, setResult] = useState({ total: "--", success: "--", failed: "--" });

	useEffect(() => {
		console.log("useEffect[] 上传商品编码确定后");
		visible === "ProgressModal" &&
			props.handleCommand("上传商品编码确定后", selectedRows, ({ success, data }) => {
				if (success) {
					setVisible("ResultModal");
					setResult(data);
				} else {
					message.warning("提交失败");
					props.onCancel();
				}
			});
	}, []);

	return (
		<>
			<ProgressModal
				visible={visible === "ProgressModal"}
				title="上传商品编码"
				onCancel={() => {
					{
						/* props.onCancel(); */
					}
					setVisible("ResultModal");
				}}
			/>
			<ResultModal
				visible={visible === "ResultModal"}
				onCancel={props.onCancel}
				onOk={() => setVisible("----")}
				result={result}
				isSkuType={isSkuType}
				actionType={"upload-sku-code"}
			/>
		</>
	);
}

export default ActionModal;
